package com.saint.lt.domain;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "issues")
public class Issue {

	@Override
	@Deprecated
	public String toString() {
		return "Issue \n\t[id=" + id + ", \n\tpriority=" + priority + ", \n\ttype=" + type
				+ ", \n\thead=" + head + ", \n\tdesc=" + desc + ", \n\tauthor=" + author
				+ ", \n\tresponsible=" + responsible + "]";
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private int id;
	
	@Enumerated(EnumType.STRING)
	@Column(name = "priority")
	private Priority priority;
	
	@Enumerated(EnumType.STRING)
	@Column(name = "type")
	private IssueType type;
	
	@Column(name = "head")
	private String head;
	
	@Column(name = "desc")
	private String desc;
	
	@ManyToOne(fetch=FetchType.LAZY, targetEntity = User.class)
	@JoinColumn(name="author")
	private User author;

	@ManyToOne(fetch=FetchType.LAZY, targetEntity = User.class)
	@JoinColumn(name="responsible")
	private User responsible;
	
	@OneToMany(mappedBy = "issue", targetEntity = Comment.class)
	private List<Comment> comments;
	
	public List<Comment> getComments() {
		return comments;
	}

	public void setComments(List<Comment> comments) {
		this.comments = comments;
	}

	public User getResponsible() {
		return responsible;
	}

	public void setResponsible(User responsible) {
		this.responsible = responsible;
	}

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Priority getPriority() {
		return priority;
	}

	public void setPriority(Priority priority) {
		this.priority = priority;
	}

	public IssueType getType() {
		return type;
	}

	public void setType(IssueType type) {
		this.type = type;
	}

	public String getHead() {
		return head;
	}

	public void setHead(String head) {
		this.head = head;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}
	
}
